<?php
namespace app\manage\model;
use think\Db;
use think\Model;

/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 2019/8/5
 * Time: 16:06
 */
class ApartmentSettings extends Model
{
    /**
     * 公寓设置显示页面
     * @return false|\PDOStatement|string|\think\Collection
     */
    public function index(){
        $data = input();
        $where['create_id'] = create_id($data['token']);
        //一级设置名
        $data=Db::name('settings')
            ->where($where)
            ->where(['apartment_state'=>1])
            ->find();
        /*$data['property_fee']=explode('',$data['property_fee']);
        $data['net_fee']=explode('',$data['net_fee']);
        $data['gas_fee']=explode('',$data['gas_fee']);
        $data['electricity_fees']=explode('',$data['electricity_fees']);
        $data['water']=explode('',$data['water']);*/
        //var_dump($data);exit;
        //二级关联的值
        /*foreach($data as $k=>$v){
            $data[$k]['apartment_value']=Db::name('apartment_value')
                ->field('sv_id,sv_value')
                ->where(['as_id'=>$v['apartment_id']])
                ->where(['sv_state'=>1])
                ->select();
        }*/
        return $data;
    }

    /**
     * 公寓设置显示页面
     * @return false|\PDOStatement|string|\think\Collection
     */
    public function index2($create_id){
        $where['create_id'] = $create_id;
        //一级设置名
        $data=Db::name('settings')
            ->where($where)
            ->where(['apartment_state'=>1])
            ->find();
        /*$data['property_fee']=explode('',$data['property_fee']);
        $data['net_fee']=explode('',$data['net_fee']);
        $data['gas_fee']=explode('',$data['gas_fee']);
        $data['electricity_fees']=explode('',$data['electricity_fees']);
        $data['water']=explode('',$data['water']);*/
        //var_dump($data);exit;
        //二级关联的值
        /*foreach($data as $k=>$v){
            $data[$k]['apartment_value']=Db::name('apartment_value')
                ->field('sv_id,sv_value')
                ->where(['as_id'=>$v['apartment_id']])
                ->where(['sv_state'=>1])
                ->select();
        }*/
        return $data;
    }
}